/*
 * @Author: 郑子胜(Zechariahzheng)
 * @Date: 2023-12-06 14:37:09
 * @LastEditors: 郑子胜(Zechariahzheng)
 * @LastEditTime: 2023-12-17 16:00:40
 * @Descripttion: 
 */
#ifndef WX_CONFIG__
#define WX_CONFIG__
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <EEPROM.h>
#include <Ticker.h>

#define DEBUGL 1

#ifdef DEBUGL
  #define WX_DEBUG_PRINT(x)  Serial.print (x)
  #define WX_DEBUG_PRINTLN(x) Serial.println (x)
#else
  #define WX_DEBUG_PRINT(x)
  #define WX_DEBUG_PRINTLN(x)
#endif

/**
* 结构体，用于存储配网信息
*/
struct config_type
{
  char stassid[32];
  char stapsw[64];
  char cuid[40];
  char ctopic[32];
  uint8_t reboot;
  uint8_t magic;
};
class WxConfig {
private:
  config_type config;
  Ticker delayTimer;
  char config_flag;

  void loadConfig();
  void waitKey();
  void initWiFi();

  void restoreFactory();
  void saveConfig();
  void delayRestart(float t);
  void doSmartconfig();

public:
  void init();
};

#endif